package genericity;

import java.lang.reflect.Array;
import java.util.Arrays;

class ArrayMaker<T> {
    private Class<T> tClass;

    public ArrayMaker(Class<T> t) {
        this.tClass = t;
    }

    public T[] make(int n) {
        return (T[]) Array.newInstance(tClass, n);
    }
}

/**
 * 创建一个数组
 */
public class ArrayMakerDemo {

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new ArrayMaker<String>(String.class).make(10)));
    }
}
